<template>
  <c-form-dialog
    ref="form"
    :visible.sync="innerVisible"
    :form-items="formItems"
    :form-data="formData"
    :table-name="tableName"
    :table-id="tableId"
    @close="handleClose"
    @success="handleSuccess"
    :before-save="handleBeforeSave"
  ></c-form-dialog>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  components: {},
  props: {
    visible: Boolean,
    formData: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  data() {
    return {
      innerVisible: false,
      tableName: 'exh_period_xl',
      formItems: [
        {
          tag: 'upload',
          itemAttrs: {
            label: '展期确认表（下载确认表后盖章上传）',
            // rules: [{ required: true, message: '请上传展期确认表', trigger: 'change' }],
          },
          attrs: {
            class: 'form-control-ml',
            key: 'exh_confirm_attachment',
            value: '',
            placeholder: '展期确认表',
            accept: '',
            fileName: 0,
            listType: '',
            dir: `/bank/limit/period/${+new Date()}/${this.tableId}`,
          },
        },
      ],
    }
  },
  computed: {
    ...mapGetters(['user', 'clientId']),
    tableId() {
      // 从其他表查的数据确保没有id这个字段
      return this.formData.id || ''
    },
  },
  watch: {
    visible(val) {
      this.innerVisible = val
    },
  },
  created() {},
  mounted() {},
  methods: {
    handleBeforeSave(model) {
      return model
    },
    handleClose() {
      this.$emit('update:visible', false)
    },
    handleSuccess(res) {
      this.$emit('success', res)
    },
  },
}
</script>
<style lang="scss" scoped></style>
